from functools import wraps

class logit(object):
    def __init__(self, logfile="out333.log"):
        self.logfile = logfile

    def __call__(self, func ):
        @wraps(func)
        def with_logging(*args, **kwargs):
            log_string = func.__name__ + " was called"
            print(log_string)
            # 写入日志文件, with异常判断和关闭文件:try except finally f.close()
            with open(self.logfile, 'a') as fs:
                fs.write(log_string + '\n')
            self.notify()
            return func(*args, **kwargs)
        return with_logging

    def notify(self):
        pass
class email_logit(logit):
    def __init__(self, email="admin@myproject.com", *args, **kwargs):
        self.emial = email
        super(email_logit, self).__init__(*args, **kwargs)

    def notify(self):
        pass

@logit()
def myfunc1():
    # 发送一封email到self.email
    # 这里就不做实现了
    pass
myfunc1()

